package com.bsit.obu.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.bsit.obu.R;


public class ToastDialog extends Dialog {
    Context context;
    InvoiceTypeListener invoiceTypeListener;
    TextView titleTv;
    TextView contentTv;
    Button cancel;
    Button confrim;
    private String title = "";
    private String content = "";


    public ToastDialog(@NonNull Context context, String title, String content, InvoiceTypeListener invoiceTypeListener) {
        super(context, R.style.transparentFrameWindowStyle);
        this.context = context;
        this.invoiceTypeListener = invoiceTypeListener;
        this.title = title;
        this.content = content;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_toast_layout);
        titleTv=findViewById(R.id.title);
        titleTv.setText(title);
        contentTv=findViewById(R.id.content);
        contentTv.setText(content);
        cancel=findViewById(R.id.cancel);
        confrim=findViewById(R.id.confrim);
        confrim.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(invoiceTypeListener!=null){
                    invoiceTypeListener.confrim();
                }
                dismiss();
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(invoiceTypeListener!=null){
                    invoiceTypeListener.cancel();
                }
                dismiss();
            }
        });

    }

    public interface InvoiceTypeListener {
        void cancel();

        void confrim();

    }
}
